home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_01_04
/
1n04039b
< prev
next >
Wrap
Text File
|
1990-07-23
|
583b
|
39 lines
Listing 3
const
HT = chr(9);
CR = chr(13);
SPACES = [' ', HT, CR];
function atoi(s : string) : integer;
var
i, n : integer;
neg : boolean;
begin
i := 1;
while (i <= length(s)) and (s[i] in SPACES) do
inc(i);
neg := FALSE;
if i <= length(s) then
if s[i] = '+' then
inc(i)
else if s[i] = '-' then
begin
neg := TRUE;
inc(i);
end;
n := 0;
while (i <= length(s)) and (s[i] in ['0' .. '9']) do
begin
n := 10 * n + ord(s[i]) - ord('0');
inc(i);
end;
if neg then
n := -n;
atoi := n;
end;
----------